<?php
/* @var $this IssueController */
/* @var $model Issue */
/* @var $form CActiveForm */
?>

<div class="form">
	<?php if(count($model->getErrors()) > 0):?>		
		<div class="alert alert-danger">
			<?php echo BSHtml::errorSummary($model); ?>		
		</div>
	<?php endif;?>
	<?php echo BSHtml::beginForm(); ?>
	<fieldset>
		<legend><?php echo $model->isNewRecord ? 'Создать' : 'Редактировать'; ?></legend>
		<p class="note">Поля, помеченные <span class="required">*</span> обязательны для заполнения.</p>
		<?php if(!Yii::app()->user->checkAccess("customer")): ?>
			<div class="form-group">
				<?php echo BSHtml::activeLabelEx($model,'status', array('class'=>'col-lg-2')); ?>
				<div class="col-lg-10">
					<?php echo BSHtml::activeDropDownList($model,'status', Issue::getStatuses()); ?>
				</div>
			</div>

			<div class="form-group">
				<?php echo BSHtml::activeLabelEx($model,'type', array('class'=>'col-lg-2')); ?>
				<div class="col-lg-10">
					<?php echo BSHtml::activeDropDownList($model,'type', Issue::getTypes()); ?>
				</div>
			</div>
		<?php else:?>
			<?php $model->status = 0;?>
			<?php $model->type = 0;?>
			<?php echo CHtml::activeHiddenField($model, 'status');?>
			<?php echo CHtml::activeHiddenField($model, 'type');?>
		<?php endif; ?>

		<div class="form-group">
			<?php echo BSHtml::activeLabelEx($model,'name', array('class'=>'col-lg-2')); ?>
			<div class="col-lg-10">
				<?php echo BSHtml::activeTextField($model,'name', array('placeholder'=>'Краткое описание задачи')); ?>
			</div>
		</div>

		<div class="form-group">
			<?php echo BSHtml::activeLabelEx($model,'description', array('class'=>'col-lg-2')); ?>
			<div class="col-lg-10">
				<?php echo BSHtml::activeTextArea($model,'description', array('placeholder'=>'Подробное описание задачи')); ?>
			</div>
		</div>

		<div class="form-group">
			<?php echo BSHtml::activeLabelEx($model,'id_project', array('class'=>'col-lg-2')); ?>
			<div class="col-lg-10">
				<?php echo BSHtml::activeDropDownList($model,'id_project',
					CHtml::listData(Project::model()->findAll(), 'id', 'name')
				); ?>
			</div>
		</div>

		<?php if(!Yii::app()->user->checkAccess("customer")): ?>
			<div class="form-group">
				<?php echo BSHtml::activeLabelEx($model,'id_user_assignee', array('class'=>'col-lg-2')); ?>
				<div class="col-lg-10">
					<?php echo BSHtml::activeDropDownList($model,'id_user_assignee',
						BSHtml::listData(User::model()->findAll(), 'id', 'name')
					); ?>
				</div>
			</div>
			<div class="form-group">
				<?php echo BSHtml::activeLabelEx($model,'id_chunk', array('class'=>'col-lg-2')); ?>
				<div class="col-lg-10">
					<?php echo BSHtml::activeTextField($model,'id_chunk'); ?>
				</div>
			</div>
		<?php endif; ?>
		<div class="form-group">
			<div class="col-lg-10 col-lg-offset-2 align-right">
				<?php 
					if(!$model->isNewRecord)
						echo BSHtml::link('Удалить', array('delete', 'id'=>$model->id), array(
							'onclick' => 'return confirm("Вы уверены, что хотите удалить задачу?")'
						)); 
				?>
				<?php echo BSHtml::submitButton($model->isNewRecord ? 'Создать' : 'Сохранить'); ?>
			</div>
		</div>
		
	</fieldset>
<?php echo BSHtml::endForm(); ?>

</div><!-- form -->